<template>
  <Layout>
    <Form ref="queryForm" :model="dataToQuery" :label-width="125">
      <Row  class="query-form">
		  <Col  span="8" >
		    <FormItem label="通知公告：">
		      <Input class="query-form-el" type="text" v-model="dataToQuery.noticName"  @on-focus="querySelect" :readonly="true"></Input>
		    </FormItem>
		  </Col>
        <Col span="8">
          <FormItem label="所属单位：">
            <cascaderDom ref="queryOrgCascader" @setOrgInfo="setOrgId"
                         :rootOrgId="companyId" class="query-form-el"
                         :orgTree="true"></cascaderDom>
          </FormItem>
        </Col>
       <!-- <Col span="8">
          <FormItem label='正副处：'>
            <Select v-model='dataToQuery.adminLevel' clearable class='query-form-el'>
              <Option value="AD-000001000000001">正处</Option>
              <Option value="AD-000001000000002">副处</Option>
              <Option value="AD-000001000000003">副处以下</Option>
            </Select>
          </FormItem>
        </Col> -->
<!--        <Col span="8">
          <FormItem label="创建时间：" prop="content" >
            <DatePicker class="query-form-el" v-model="dataToQuery.createDateRange" format="yyyy-MM-dd" type="daterange" placement="bottom-end" placeholder="请选择创建时间段"
                        @on-change="(date) => onSelectFieldQueryDateRange(date, 'createDate')"	></DatePicker>
          </FormItem>
        </Col>-->
        <Col span="8" v-if="!switchFlag">
          <Button @click="switchQuery(true)" class="ivu-btn-switch" type="text">展开∨</Button>
          <Button @click="reseter" class="ivu-btn-reset">重置</Button>
          <Button type="primary" class="ivu-btn-query" icon="md-search" @click="query">查询</Button>
        </Col>
        <Col span="8" v-else>
          <FormItem label="企业搜索：">
            <Input class="query-form-el" placeholder="输入公司名称" v-model="dataToQuery.orgName"></Input>
          </FormItem>
        </Col>
      </Row>
      <Row v-show="switchFlag" class="query-form">

        <Col span="8" :offset="16">
          <Button @click="switchQuery(false)" class="ivu-btn-switch" type="text">收起∧</Button>
          <Button @click="reseter" class="ivu-btn-reset">重置</Button>
          <Button type="primary" class="ivu-btn-query" icon="md-search" @click="query">查询</Button>
        </Col>
      </Row>
    </Form>
	<Row class="query-form">
	  <Col span="24">
	    <Button type="primary" class="ivu-btn-add" icon="md-cloud-download" @click="exportFormSubmit">导出
	    </Button>
	  </Col>
	</Row>
    <Table ref='table' :height="tableHeight" no-data-text="没有查询到相关数据!" @on-selection-change='getSelectRows'
           :loading='pageStatus.loading'
           border :columns="columns1" :data="dataTable">
    </Table>
    <Row style="margin-right:10px;">
      <Col span="24">
        <Page style="float: right" :total="pagedata.total" :page-size="pagedata.pageSize"
              @on-change="pageChange" @on-page-size-change="pageSizeChange" :page-size-opts="pageSizeArray"
              show-total show-sizer show-elevator/>
      </Col>
    </Row>
    <Modal title="选择通知公告" :transfer=false footer-hide v-model="queryMeetingSelectModal" :width=900>
      <noticeSelect ref="selQueryMission" :noticeType="2" @selectMission="queryMetting">
      </noticeSelect>
    </Modal>

  </Layout>
</template>

<script>
import {Api} from '@/api/index.js'
import noticeSelect from '@/views/safe/receipt/NoticeSelect.vue'
import {sessionStorage} from '@/common/cacheUtils.js';
import pageCommonFunction from '@/components/pageCommonFunction.js'

var cascaderDom = () => import('@/components/cascader-dom.vue');
export default {
  components: {cascaderDom, noticeSelect},
  data() {
    return {
      ...this.createCommonDataField(),
      queryMeetingSelectModal: false,
      columns1: [
        {title: '序号', width: 80, fixed: 'left', align: 'center', render: this.indexColumnsRender},
        {key: 'companyName', title: '单位',fixed: 'left', align: 'center', minWidth: 200},
        {key: 'twoLevelName', title: '所属二级集团', fixed: 'left', align: 'center', minWidth: 200},
        // {key: 'levelName', title: '正副处', align: 'center', minWidth: 100},
        {key: 'num', title: '参会人数', align: 'center', minWidth: 100},
        {key: 'MeetingReceipt', title: '会议回执情况', align: 'center', minWidth: 100},
        // {key: 'isTrue', title: '会议签到', align: 'center', minWidth: 100},
      ],
      tableHeight: 10,
      companyId:'',
      buttonLoading:false,
      // api
      queryUrl: Api.queryCountReceipt,
	  exportUrl: Api.exportCountReceipt,
      getNotic:Api.queryNotic,
    }
  },
  mounted() {
    this.companyId = sessionStorage('userId').getObject('userId').companyId
    this.tableHeight = window.innerHeight - this.$refs.table.$el.offsetTop - 145;
    this.$Modal.warning({
      title: '提示',
      content: '<p>请选择通知公告！</p>',
      onOk: () => {
        this.querySelect();
      }
    });

  },
  methods: {
    ...pageCommonFunction,
    query() {
      if (this.dataToQuery.adminLevel != null && this.dataToQuery.adminLevel != undefined && this.dataToQuery.adminLevel.length < 1) {
        this.dataToQuery.adminLevel=null
      }
      if (this.dataToQuery.companyId != null&&this.dataToQuery.companyId != undefined&&this.dataToQuery.companyId != '') {
        this.dataToQuery.orgId=this.dataToQuery.companyId
      }else {
        this.dataToQuery.orgId = sessionStorage('userId').getObject('userId').companyId
      }
      this.queryAjax();

    },
    queryMetting(row){
      this.queryMeetingSelectModal = false;
      this.dataToQuery.noticId = row.proposalId;
      this.dataToQuery.noticName = row.title;
    },
    setOrgId(data) {
      this.dataToQuery.companyId = data[data.length - 1];
    },
    querySelect() {
      this.queryMeetingSelectModal = true

    },
    reseter(){
      this.dataToQuery = {
        noticId: this.dataToQuery.noticId,
        noticName: this.dataToQuery.noticName
      };
      if (this.$refs.queryOrgCascader) {
        this.$refs.queryOrgCascader.resetCurrentOrg();
      }
      if (this.$refs.queryOrgCascader1) {
        this.$refs.queryOrgCascader1.resetCurrentOrg();
      }
      this.pagedata.currentPage=1

      this.query();

    }
  },
  computed: {},

}
</script>

<style lang='css' scoped>
@import '../../../index.css';
</style>
